<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">个人推广统计</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Member/promoters')}">
        <label>个人推广</label>
        <select style="width:150px;" name="store_parent_id" id="store_id">
            <option value="">请选择</option>
            <foreach name="storeList" item="s">
                <option value="{$s.store_id}" <if condition="$search_arr['store_parent_id'] eq $s['store_id']">selected</if>>{$s.store_name}</option>
            </foreach>
        </select>

        <div class="form-group">
            <label for="exampleInputName3">统计方式</label>
            <select class="form-control" style="height: 35px;" id="type" name="type">
                <option value="month" <if condition="$search_arr['type'] eq 'month'">selected</if> >按月统计</option>
                <option value="week"  <if condition="$search_arr['type'] eq 'week'">selected</if>>按周统计</option>
            </select>
        </div>
        <div <if condition="$search_arr['type'] eq 'week'">style="display: none"</if> class="form-group" id="month_to">
            <select class="form-control" style="height: 35px;" name="searchmonth_year">
                <foreach name="year_arr" item="v" key="k">
                    <option value="{$k}" <if condition="$search_arr['searchmonth_year'] eq $k">selected</if>>{$v}</option>
                </foreach>
            </select>
            <select class="form-control" style="height: 35px;" name="searchmonth_month">
                <foreach name="month_arr" item="v" key="k">
                    <option value="{$k}" <if condition="$search_arr['searchmonth_month'] eq $k">selected</if>>{$v}</option>
                </foreach>
            </select>
        </div>

        <div <if condition="$search_arr['type'] eq 'month' || $search_arr['type'] eq ''">style="display: none"</if> id="week_to"  class="form-group">
            <select class="form-control" style="height: 35px;" name="searchweek_year">
                <foreach name="year_arr" item="v" key="k">
                    <option value="{$k}" <if condition="$search_arr['week']['current_year'] eq $k">selected</if>>{$v}</option>
                </foreach>
            </select>
            <select class="form-control" style="height: 35px;" name="searchweek_month">
                <foreach name="month_arr" item="v" key="k">
                    <option value="{$k}" <if condition="$search_arr['week']['current_month'] eq $k">selected</if>>{$v}</option>
                </foreach>
            </select>
            <select class="form-control" style="height: 35px;" name="searchweek_week">
                <foreach name="week_arr" item="v" key="k">
                    <option value="{$v.key}" <if condition="$search_arr['week']['current_week'] eq $v['key']">selected</if>>{$v.val}</option>
                </foreach>
            </select>
        </div>

        <button type="submit" class="btn btn-success">查询</button>
        <a href="{:U('Member/promoters')}" class="btn btn-warning">清空</a>
    </form>
<table class="table table-hover table-bordered table-list">
    <thead>
    <tr>
        <th>ID</th>
        <th>用户手机号</th>
        <th>姓名</th>
        <th>申请手机号</th>
        <th>身份证号</th>
        <th>银行名称</th>
        <th>开户行</th>
        <th>卡号</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <foreach name="promotersList" item ="vo">
        <tr>
            <td>{$vo.user_id}</td>
            <td>{$vo.phone}</td>
            <td>{$vo.name}</td>
            <td>{$vo.phone_mob}</td>
            <td>{$vo.user_no}</td>
            <td>{$vo.bank}</td>
            <td>{$vo.open_bank}</td>
            <td>{$vo.bank_card}</td>
            <td>
                <if condition="$vo['is_show']">
                    <a href="{:U('Member/pdf',array('id'=>$vo['user_id']))}">导出pdf</a>
                    <else/>
                    无操作
                </if>
            </td>
        </tr>
    </foreach>
    </tbody>
</table>
<div class="pagination">{$page}</div>
</div>




<div class="row">
    <div id="echartsDiv" style="width: 1200px;height:600px;margin-top: 50px;margin-left: 20px;"></div>
</div>
<script src="__PUBLIC__/js/echarts-all.js"></script>
<script src="__PUBLIC__/js/common.js"></script>

<input type="hidden" value='{$stat_json}' name="stat_json">
<!-- iframe自适应高度 -->
</body>
<script type="text/javascript">

    //获取统计数据
    var stat_json = JSON.parse($("[name=stat_json]").val());
    var myChart = echarts.init(document.getElementById('echartsDiv'));

    option = {
        title: {
            // text: '某地区蒸发量和降水量',
            // subtext: '纯属虚构'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: []
        },
        toolbox: {
            show: true,
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        calculable: true,
        xAxis:stat_json.xAxis,
        yAxis: [
            {
                type: 'value',

            }
        ],
        series: stat_json.series
    };
    myChart.setOption(option);

</script>
<script>

    $("#type").change(function(){
        var type = $(this).val();
        if(type == 'month'){
            $("#week_to").hide();
            $("#month_to").show();
        }else if(type == 'week'){
            $("#week_to").show();
            $("#month_to").hide();
        }
    })
    //更新周数组
    $("[name='searchweek_month']").change(function() {
        var year = $("[name='searchweek_year']").val();
        var month = $("[name='searchweek_month']").val();
        $("[name='searchweek_week']").html('');
        var url = "{:U('Member/getweekofmonth')}";
        $.post(url,{
            y:year,
            m:month
        },function(data){
            var res = JSON.parse(data)
            if (res != null) {
                for (var i = 0; i < res.length; i++) {
                    $("[name='searchweek_week']").append('<option value="' + res[i].key + '">' + res[i].val + '</option>');
                }
            }
        })
    });


</script>

</html>
